Skip to contentSkip to conversation

Change in openvpn[master]: management: resync timer on bytecount interval change

Openvpn-devel Superseded ralf_lici (Code Review) 2 participants 16 messages Jul 25, 2025 – Sep 2, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1753449319000.Ic0035d52e0ea123398318870d2f4d21af927a602@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email

to review the following change.

Change subject: management: resync timer on bytecount interval change
......................................................................

management: resync timer on bytecount interval change

coarse_timer_wakeup tracks when the next timer-driven task will occur. When a user issues bytecount n on the management interface but the existing wakeup is more than n seconds ahead, bandwidth logging won’t run until that original timer fires, delaying logs.

Introduce a flag to detect when the bytecount interval changes and, when set, recalculate coarse_timer_wakeup so logging fires exactly n seconds after the command. This guarantees bytecount adheres to the user-specified interval.

Change-Id Ic0035d52e0ea123398318870d2f4d21af927a602

---
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/manage.h

3 files changed, 15 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/1113/1

src/openvpn/forward.c +13 -0
index a4f260a..192fff4 100644
@@ -838,6 +838,19 @@
 static void
 check_coarse_timers(struct context *c)
 {
+#ifdef ENABLE_MANAGEMENT
+    /* The 'bytecount' command starts a timer at runtime, but it would not be
+     * processed if coarse_timer_wakeup was previously set to a higher value.
+     * Therefore, if the command has arrived, we reset coarse_timer_wakeup in
+     * to order to update it accordingly.
+     */
+    if (management && management->connection.bytecount_interval_changed)
+    {
+        reset_coarse_timers(c);
+        management->connection.bytecount_interval_changed = false;
+    }
+#endif /* ENABLE_MANAGEMENT */
+
     if (now < c->c2.coarse_timer_wakeup)
     {
         context_reschedule_sec(c, c->c2.coarse_timer_wakeup - now);
src/openvpn/manage.c +1 -0
index 8836e79..0df78ee 100644
@@ -503,6 +503,7 @@
         man->connection.bytecount_update_seconds = 0;
         event_timeout_clear(&man->connection.bytecount_update_interval);
     }
+    man->connection.bytecount_interval_changed = true;
     msg(M_CLIENT, "SUCCESS: bytecount interval changed");
 }
 
src/openvpn/manage.h +1 -0
index eb19a4e..00e3931 100644
@@ -318,6 +318,7 @@
     bool state_realtime;
     bool log_realtime;
     bool echo_realtime;
+    bool bytecount_interval_changed;
     int bytecount_update_seconds;
     struct event_timeout bytecount_update_interval;
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos, ralf_lici.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email )

Change subject: management: resync timer on bytecount interval change
......................................................................

Patch Set 1: Code-Review-1

(1 comment)

Patchset:

PS1:
please rebase on current master to fix build issue

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Comment-Date: Fri, 25 Jul 2025 16:40:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

ralf_lici has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email )

Change subject: management: resync timer on bytecount interval change
......................................................................

Patch Set 2:

(1 comment)

Patchset:

PS1:

Quoted 1 line

please rebase on current master to fix build issue

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 25 Jul 2025 16:46:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email )

Change subject: management: resync timer on bytecount interval change
......................................................................

Patch Set 2: -Code-Review

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Mon, 28 Jul 2025 10:04:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos, ralf_lici.

stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email )

Change subject: management: resync timer on bytecount interval change
......................................................................

Patch Set 2: Code-Review+2

(1 comment)

Patchset:

PS2:
LGTM.

I am not quite sure why this is needed, at least in my tests I never had to wait for a long for timer to be fired and the new value applied, but I guess make it more real-time won't harm.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Comment-Date: Fri, 29 Aug 2025 12:04:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#6 lore raw

PATCH v2 1/1 management: resync timer on bytecount interval change

In reply to a message not in the archive

From: Ralf Lici <[email protected]...>

coarse_timer_wakeup tracks when the next timer-driven task will occur. When a user issues bytecount n on the management interface but the existing wakeup is more than n seconds ahead, bandwidth logging won’t run until that original timer fires, delaying logs.

Introduce a flag to detect when the bytecount interval changes and, when set, recalculate coarse_timer_wakeup so logging fires exactly n seconds after the command. This guarantees bytecount adheres to the user-specified interval.

Change-Id Ic0035d52e0ea123398318870d2f4d21af927a602

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1113
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Lev Stipakov <[email protected]...>

src/openvpn/forward.c +13 -0
index dfc6708..1c9b4f8 100644
@@ -838,6 +838,19 @@
 static void
 check_coarse_timers(struct context *c)
 {
+#ifdef ENABLE_MANAGEMENT
+    /* The 'bytecount' command starts a timer at runtime, but it would not be
+     * processed if coarse_timer_wakeup was previously set to a higher value.
+     * Therefore, if the command has arrived, we reset coarse_timer_wakeup in
+     * to order to update it accordingly.
+     */
+    if (management && management->connection.bytecount_interval_changed)
+    {
+        reset_coarse_timers(c);
+        management->connection.bytecount_interval_changed = false;
+    }
+#endif /* ENABLE_MANAGEMENT */
+
     if (now < c->c2.coarse_timer_wakeup)
     {
         context_reschedule_sec(c, c->c2.coarse_timer_wakeup - now);
src/openvpn/manage.c +1 -0
index 8836e79..0df78ee 100644
@@ -503,6 +503,7 @@
         man->connection.bytecount_update_seconds = 0;
         event_timeout_clear(&man->connection.bytecount_update_interval);
     }
+    man->connection.bytecount_interval_changed = true;
     msg(M_CLIENT, "SUCCESS: bytecount interval changed");
 }
 
src/openvpn/manage.h +1 -0
index eb19a4e..00e3931 100644
@@ -318,6 +318,7 @@
     bool state_realtime;
     bool log_realtime;
     bool echo_realtime;
+    bool bytecount_interval_changed;
     int bytecount_update_seconds;
     struct event_timeout bytecount_update_interval;
 
#7 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos, ralf_lici, stipa.

Hello flichtenheld, plaisthos, stipa,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email

to look at the new patch set (#3).

The following approvals got outdated and were removed:
Code-Review+2 by stipa

The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.

Change subject: management: resync timer on bytecount interval change
......................................................................

management: resync timer on bytecount interval change

coarse_timer_wakeup tracks when the next timer-driven task will occur. If a user issues bytecount n via the management interface, but the next scheduled wakeup is more than n seconds away, bandwidth logging will be delayed until that timer fires.

To ensure timely logging, reset the timer whenever a new bytecount command is received. This guarantees that logging begins exactly n seconds after the command, matching the user-defined interval.

Change-Id Ic0035d52e0ea123398318870d2f4d21af927a602

---
M src/openvpn/manage.c

1 file changed, 23 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/1113/3

src/openvpn/manage.c +23 -0
index aed04f5..53a3e4e 100644
@@ -41,6 +41,7 @@
 #include "manage.h"
 #include "openvpn.h"
 #include "dco.h"
+#include "multi.h"
 
 #include "memdbg.h"
 
@@ -513,6 +514,28 @@
         man->connection.bytecount_update_seconds = 0;
         event_timeout_clear(&man->connection.bytecount_update_interval);
     }
+
+    /* The newly received bytecount interval may be sooner than the existing
+     * coarse timer wakeup. Reset the timer to ensure it fires at the correct,
+     * earlier time.
+     */
+    if (man->persist.callback.arg)
+    {
+        struct context *c;
+
+        if (man->settings.flags & MF_SERVER)
+        {
+            struct multi_context *m = man->persist.callback.arg;
+            c = &m->top;
+        }
+        else
+        {
+            c = man->persist.callback.arg;
+        }
+
+        reset_coarse_timers(c);
+    }
+
     msg(M_CLIENT, "SUCCESS: bytecount interval changed");
 }
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 3
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset

#8 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos, ralf_lici, stipa.

Hello flichtenheld, plaisthos, stipa,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email

to look at the new patch set (#4).

Change subject: management: resync timer on bytecount interval change
......................................................................

management: resync timer on bytecount interval change

coarse_timer_wakeup tracks when the next timer-driven task will occur. If a user issues bytecount n via the management interface, but the next scheduled wakeup is more than n seconds away, bandwidth logging will be delayed until that timer fires.

To ensure timely logging, reset the timer whenever a new bytecount command is received. This guarantees that logging begins exactly n seconds after the command, matching the user-defined interval.

Change-Id Ic0035d52e0ea123398318870d2f4d21af927a602

---
M src/openvpn/manage.c

1 file changed, 22 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/1113/4

src/openvpn/manage.c +22 -0
index aed04f5..92c5500 100644
@@ -41,6 +41,7 @@
 #include "manage.h"
 #include "openvpn.h"
 #include "dco.h"
+#include "multi.h"
 
 #include "memdbg.h"
 
@@ -513,6 +514,27 @@
         man->connection.bytecount_update_seconds = 0;
         event_timeout_clear(&man->connection.bytecount_update_interval);
     }
+
+    /* The newly received bytecount interval may be sooner than the existing
+     * coarse timer wakeup. Reset the timer to ensure it fires at the correct,
+     * earlier time.
+     */
+    ASSERT(man->persist.callback.arg);
+
+    struct context *c;
+
+    if (man->settings.flags & MF_SERVER)
+    {
+        struct multi_context *m = man->persist.callback.arg;
+        c = &m->top;
+    }
+    else
+    {
+        c = man->persist.callback.arg;
+    }
+
+    reset_coarse_timers(c);
+
     msg(M_CLIENT, "SUCCESS: bytecount interval changed");
 }
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 4
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset

#9 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos, ralf_lici, stipa.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email )

Change subject: management: resync timer on bytecount interval change
......................................................................

Patch Set 4: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 4
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Tue, 02 Sep 2025 10:16:07 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#10 lore raw

PATCH v4 1/1 management: resync timer on bytecount interval change

In reply to a message not in the archive

From: Ralf Lici <[email protected]...>

coarse_timer_wakeup tracks when the next timer-driven task will occur. If a user issues bytecount n via the management interface, but the next scheduled wakeup is more than n seconds away, bandwidth logging will be delayed until that timer fires.

To ensure timely logging, reset the timer whenever a new bytecount command is received. This guarantees that logging begins exactly n seconds after the command, matching the user-defined interval.

Change-Id Ic0035d52e0ea123398318870d2f4d21af927a602

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1113
This mail reflects revision 4 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/manage.c +22 -0
index aed04f5..92c5500 100644
@@ -41,6 +41,7 @@
 #include "manage.h"
 #include "openvpn.h"
 #include "dco.h"
+#include "multi.h"
 
 #include "memdbg.h"
 
@@ -513,6 +514,27 @@
         man->connection.bytecount_update_seconds = 0;
         event_timeout_clear(&man->connection.bytecount_update_interval);
     }
+
+    /* The newly received bytecount interval may be sooner than the existing
+     * coarse timer wakeup. Reset the timer to ensure it fires at the correct,
+     * earlier time.
+     */
+    ASSERT(man->persist.callback.arg);
+
+    struct context *c;
+
+    if (man->settings.flags & MF_SERVER)
+    {
+        struct multi_context *m = man->persist.callback.arg;
+        c = &m->top;
+    }
+    else
+    {
+        c = man->persist.callback.arg;
+    }
+
+    reset_coarse_timers(c);
+
     msg(M_CLIENT, "SUCCESS: bytecount interval changed");
 }
 
#11 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, plaisthos, ralf_lici, stipa.

Hello cron2, flichtenheld, plaisthos, stipa,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email

to look at the new patch set (#5).

The following approvals got outdated and were removed:
Code-Review+2 by cron2

The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.

Change subject: management: resync timer on bytecount interval change
......................................................................

management: resync timer on bytecount interval change

coarse_timer_wakeup tracks when the next timer-driven task will occur. If a user issues bytecount n via the management interface, but the next scheduled wakeup is more than n seconds away, bandwidth logging will be delayed until that timer fires.

To ensure timely logging, reset the timer whenever a new bytecount command is received. This guarantees that logging begins exactly n seconds after the command, matching the user-defined interval.

Change-Id Ic0035d52e0ea123398318870d2f4d21af927a602

---
M src/openvpn/manage.c

1 file changed, 23 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/1113/5

src/openvpn/manage.c +23 -0
index aed04f5..53a3e4e 100644
@@ -41,6 +41,7 @@
 #include "manage.h"
 #include "openvpn.h"
 #include "dco.h"
+#include "multi.h"
 
 #include "memdbg.h"
 
@@ -513,6 +514,28 @@
         man->connection.bytecount_update_seconds = 0;
         event_timeout_clear(&man->connection.bytecount_update_interval);
     }
+
+    /* The newly received bytecount interval may be sooner than the existing
+     * coarse timer wakeup. Reset the timer to ensure it fires at the correct,
+     * earlier time.
+     */
+    if (man->persist.callback.arg)
+    {
+        struct context *c;
+
+        if (man->settings.flags & MF_SERVER)
+        {
+            struct multi_context *m = man->persist.callback.arg;
+            c = &m->top;
+        }
+        else
+        {
+            c = man->persist.callback.arg;
+        }
+
+        reset_coarse_timers(c);
+    }
+
     msg(M_CLIENT, "SUCCESS: bytecount interval changed");
 }
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 5
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset

#12 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos, ralf_lici, stipa.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email )

Change subject: management: resync timer on bytecount interval change
......................................................................

Patch Set 5: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 5
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Tue, 02 Sep 2025 16:00:34 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#13 lore raw

PATCH v5 1/1 management: resync timer on bytecount interval change

In reply to a message not in the archive

From: Ralf Lici <[email protected]...>

coarse_timer_wakeup tracks when the next timer-driven task will occur. If a user issues bytecount n via the management interface, but the next scheduled wakeup is more than n seconds away, bandwidth logging will be delayed until that timer fires.

To ensure timely logging, reset the timer whenever a new bytecount command is received. This guarantees that logging begins exactly n seconds after the command, matching the user-defined interval.

Change-Id Ic0035d52e0ea123398318870d2f4d21af927a602

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1113
This mail reflects revision 5 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/manage.c +23 -0
index aed04f5..53a3e4e 100644
@@ -41,6 +41,7 @@
 #include "manage.h"
 #include "openvpn.h"
 #include "dco.h"
+#include "multi.h"
 
 #include "memdbg.h"
 
@@ -513,6 +514,28 @@
         man->connection.bytecount_update_seconds = 0;
         event_timeout_clear(&man->connection.bytecount_update_interval);
     }
+
+    /* The newly received bytecount interval may be sooner than the existing
+     * coarse timer wakeup. Reset the timer to ensure it fires at the correct,
+     * earlier time.
+     */
+    if (man->persist.callback.arg)
+    {
+        struct context *c;
+
+        if (man->settings.flags & MF_SERVER)
+        {
+            struct multi_context *m = man->persist.callback.arg;
+            c = &m->top;
+        }
+        else
+        {
+            c = man->persist.callback.arg;
+        }
+
+        reset_coarse_timers(c);
+    }
+
     msg(M_CLIENT, "SUCCESS: bytecount interval changed");
 }
 
#14 lore raw

[Openvpn-devel] [PATCH applied] Re: management: resync timer on bytecount interval change

I have tested this on client and server, including lots of extra msg() printing to verify that "the arg that we think should be a multi* or context* pointer" indeed is what we expect.

v4 was good to go, but it crashes the server if --management-hold is active and "bytecount 1" is issued (tun not open yet, so parts of the management infra are not initalized yet - in particular *.callback.arg)

So, v5 is the same as v3, just having an if() clause there. ASSERT() for "can't happen" will tell you what you overlooked ;-)

As for the commit before that, mail-archive.org refuses to acknowledge existence of the "patch on the list!" mail, so sourceforge.net is linked.

Your patch has been applied to the master branch.

commit 3bc0b2d0aea742640a1acf97fc4b41726b88ce96

Author: Ralf Lici
Date:   Tue Sep 2 18:00:44 2025 +0200
     management: resync timer on bytecount interval change

     Signed-off-by: Ralf Lici <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://sourceforge.net/p/openvpn/mailman/message/59228306/
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#15 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#6) to the change originally created by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: management: resync timer on bytecount interval change
......................................................................

management: resync timer on bytecount interval change

coarse_timer_wakeup tracks when the next timer-driven task will occur. If a user issues bytecount n via the management interface, but the next scheduled wakeup is more than n seconds away, bandwidth logging will be delayed until that timer fires.

To ensure timely logging, reset the timer whenever a new bytecount command is received. This guarantees that logging begins exactly n seconds after the command, matching the user-defined interval.

Change-Id Ic0035d52e0ea123398318870d2f4d21af927a602

Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59228306/

---
M src/openvpn/manage.c

1 file changed, 22 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/1113/6

src/openvpn/manage.c +22 -0
index 52b0e5e..422aa0b 100644
@@ -514,6 +514,28 @@
         man->connection.bytecount_update_seconds = 0;
         event_timeout_clear(&man->connection.bytecount_update_interval);
     }
+
+    /* The newly received bytecount interval may be sooner than the existing
+     * coarse timer wakeup. Reset the timer to ensure it fires at the correct,
+     * earlier time.
+     */
+    if (man->persist.callback.arg)
+    {
+        struct context *c;
+
+        if (man->settings.flags & MF_SERVER)
+        {
+            struct multi_context *m = man->persist.callback.arg;
+            c = &m->top;
+        }
+        else
+        {
+            c = man->persist.callback.arg;
+        }
+
+        reset_coarse_timers(c);
+    }
+
     msg(M_CLIENT, "SUCCESS: bytecount interval changed");
 }
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 6
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#16 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email )

Change subject: management: resync timer on bytecount interval change
......................................................................

management: resync timer on bytecount interval change

coarse_timer_wakeup tracks when the next timer-driven task will occur. If a user issues bytecount n via the management interface, but the next scheduled wakeup is more than n seconds away, bandwidth logging will be delayed until that timer fires.

To ensure timely logging, reset the timer whenever a new bytecount command is received. This guarantees that logging begins exactly n seconds after the command, matching the user-defined interval.

Change-Id Ic0035d52e0ea123398318870d2f4d21af927a602

Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59228306/

---
M src/openvpn/manage.c

1 file changed, 22 insertions(+), 0 deletions(-)
src/openvpn/manage.c +22 -0
index 52b0e5e..422aa0b 100644
@@ -514,6 +514,28 @@
         man->connection.bytecount_update_seconds = 0;
         event_timeout_clear(&man->connection.bytecount_update_interval);
     }
+
+    /* The newly received bytecount interval may be sooner than the existing
+     * coarse timer wakeup. Reset the timer to ensure it fires at the correct,
+     * earlier time.
+     */
+    if (man->persist.callback.arg)
+    {
+        struct context *c;
+
+        if (man->settings.flags & MF_SERVER)
+        {
+            struct multi_context *m = man->persist.callback.arg;
+            c = &m->top;
+        }
+        else
+        {
+            c = man->persist.callback.arg;
+        }
+
+        reset_coarse_timers(c);
+    }
+
     msg(M_CLIENT, "SUCCESS: bytecount interval changed");
 }
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Gerrit-Change-Number: 1113
Gerrit-PatchSet: 6
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged